
from pages.base_page import BasePage
from selenium.webdriver.common.by import By

class FinanceAddPaymentPage(BasePage):
    #当前页面url
    url = "/crm/index.php?m=finance&a=add&t=receivingorder"
    #定位器
    finance_add_payment_name_locator = (By.ID, "receivables")
    finance_add_payment_name_choice_locator = (By.CSS_SELECTOR, "#data > tr:nth-child(1) > td:nth-child(1) > input[type=radio]")
    finance_add_payment_name_ok_locator = (By.CSS_SELECTOR, "body > div:nth-child(8) > div.ui-dialog-buttonpane.ui-widget-content.ui-helper-clearfix > div > button:nth-child(1) > span")
    finance_add_payment_money_locator = (By.ID, "money")
    finance_add_payment_time_locator = (By.ID, "pay_time")
    choice_locator = (By.CSS_SELECTOR,
                      "body > div.container > div.row > div > form > table > tbody > tr:nth-child(7) > td:nth-child(2) > input[type=radio]:nth-child(1)")
    save_locator = (By.XPATH,
                    "/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]")
    add_payment_alert_locator = (By.CSS_SELECTOR, "body > div.container > div.alert.alert-success")

    #页面操作
    def order_payment_name_click(self):
        self.find_element(self.finance_add_payment_name_locator).click()

    def order_payment_name_choice_click(self):
        self.find_element(self.finance_add_payment_name_choice_locator).click()

    def order_payment_name_ok_click(self):
        self.find_element(self.finance_add_payment_name_ok_locator).click()

    def order_payment_money_input(self,payment_money):
        self.find_element(self.finance_add_payment_money_locator).send_keys(payment_money)

    def order_payment_time_input(self,payment_time):
        self.find_element(self.finance_add_payment_time_locator).send_keys(payment_time)

    def order_status_choice(self):
        self.find_element(self.choice_locator).click()

    def order_save_click(self):
        self.find_element(self.save_locator).click()

    def add_payment_alert(self):
        return self.find_element(self.add_payment_alert_locator).text


